/**
 * <b> 文件: </b> GetwayLog.java
 * @author xhe
 * @version V1.0.0.0
 * @version --2020-10-27
 */
package xhe.lib.log;

import xhe.entities.ApiEntity;
import xhe.lib.date.DateTime;
import xhe.lib.db.BaseFactory;

/**
 * <b> 类: </b> GetwayLog.java
 * 
 * @author xhe
 * @version V1.0.0.0
 * @version --2020-10-27
 */
public class Gateway {

	public static boolean signatureLog(ApiEntity requestEntity) {

		boolean blResult = false;

		try {
			requestEntity.setResponseTime(DateTime.toString(DateTime.now(), "yyyy-MM-dd HH:mm:ss"));

			BaseFactory oBaseFactory = new BaseFactory(requestEntity);

			String strSql = "insert into t_logs_gateway ";
			strSql += "( ";
			strSql += "		servicescode, ";
			strSql += "		bareauscode, ";
			strSql += "		bussinesscode, ";
			strSql += "		requester, ";
			strSql += "		authcode, ";
			strSql += "		clientip, ";
			strSql += "		datacode, ";
			strSql += "		datatype, ";
			strSql += "		datatotal, ";
			strSql += "		requesttime, ";
			strSql += "		responsetime, ";
			strSql += "		executetime, ";
			strSql += "		requestparams, ";
			strSql += "		responsetext, ";
			strSql += "		status, ";
			strSql += "		message, ";
			strSql += "		remarks";
			strSql += ") ";
			strSql += "values ";
			strSql += "( ";
			strSql += "    	'" + requestEntity.getServiceCode() + "', ";
			strSql += "    	'" + requestEntity.getBareausCode() + "',";
			strSql += "     '" + requestEntity.getBussinessCode() + "', ";
			strSql += "    	'" + requestEntity.getLoginName() + "', ";
			strSql += "    	'" + requestEntity.getAuthCode() + "',";
			strSql += "    	'" + requestEntity.getClientIP() + "', ";
			strSql += "     '" + requestEntity.getDataCode() + "',";
			strSql += "     '" + requestEntity.getDataType() + "', ";
			strSql += "     '" + requestEntity.getDataTotal() + "', ";
			strSql += "     '" + requestEntity.getRequestTime() + "', ";
			strSql += "    	'" + requestEntity.getResponseTime() + "', ";
			strSql += "    	" + requestEntity.getExecuteTime() + ",";
			strSql += "     '" + requestEntity.getRequest() + "', ";
			strSql += "     '" + requestEntity.getResult() + "',";
			strSql += "     " + requestEntity.getCode().getCode() + ",";
			strSql += "     '" + requestEntity.getMessage() + "', ";
			strSql += "     '" + requestEntity.getRemarks() + "'";
			strSql += ")";

			System.out.println("SQL:" + strSql);

			// 执行语句
			int iResult = oBaseFactory.Execute(strSql, requestEntity);

			// 封装返回对象
			if (iResult > 0) {

				blResult = true;
			}
		} catch (Exception ex) {

		}
		return blResult;
	}
}
